//
//  WQIntelligenceMainViewController.m
//  WisdomQuestor
//
//  Created by 纪景城 on 2024/12/18.
//

#import "WQIntelligenceMainViewController.h"
#import "WQIntelligenceRecentUseCell.h"
#import "WQIntelligenceWeatherCell.h"
#import "WQIntelligenceFunctionCell.h"

typedef NS_ENUM(NSUInteger, IntelligenceCellType) {
    IntelligenceCellTypeUse, // 最急使用
    IntelligenceCellTypeWeather, // 天气
    IntelligenceCellTypeZhiNengShouHu,
    IntelligenceCellTypeJingXuanFuWu,
};

@interface WQIntelligenceMainViewController ()

@property (nonatomic, strong) UIImageView           *backColorImageView;

@end

@implementation WQIntelligenceMainViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.edgesForExtendedLayout = UIRectEdgeAll;
    self.hbd_barTintColor = UIColor.clearColor;
    self.hbd_barAlpha = 0;
    
    [self.view addSubviews:[NSArray arrayWithObjects:self.backColorImageView, nil]];
    [self.view insertSubview:self.backColorImageView atIndex:0];
    [self fragmentUI_ViewSet];
    
}

#pragma mark ------- Http Mehods -------

- (void)requestHandlerWishIsRefresh:(BOOL)isRefresh {
    [self tableEndRefresh];
}

#pragma mark ------- UITableViewDelegate -------

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 4;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 1;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return 10;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    switch (indexPath.section) {
        case IntelligenceCellTypeUse:
            return kFragmemtFloat(130);
        case IntelligenceCellTypeWeather:
            return kFragmemtFloat(128);
            
        default:
            return kFragmemtFloat(86);
    }
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    switch (indexPath.section) {
        case IntelligenceCellTypeUse:
        {
            WQIntelligenceRecentUseCell *cell = [WQIntelligenceRecentUseCell ff_CellDequeueWithId:tableView];
            return cell;
        }
            
        case IntelligenceCellTypeWeather:
        {
            WQIntelligenceWeatherCell *cell = [WQIntelligenceWeatherCell ff_CellDequeueWithId:tableView];
            return cell;
        }
            
        case IntelligenceCellTypeZhiNengShouHu:
        {
            WQIntelligenceFunctionCell *cell = [WQIntelligenceFunctionCell ff_CellDequeueWithId:tableView];
            cell.funImageView.image = kImageName(@"intelligence_guard_ico");
            cell.funTitleLabel.text = @"智能守护";
            cell.funDescLabel.text = @"家庭报警应用，守护您的家庭安全";
            return cell;
        }
            
        case IntelligenceCellTypeJingXuanFuWu:
        {
            WQIntelligenceFunctionCell *cell = [WQIntelligenceFunctionCell ff_CellDequeueWithId:tableView];
            cell.funImageView.image = kImageName(@"intelligence_search_ico");
            cell.funTitleLabel.text = @"精选服务";
            cell.funDescLabel.text = @"与设备相关的虚拟服务";
            return cell;
        }
            
        default:
            return [UITableViewCell ff_CellDequeueWithId:tableView];
    }
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
}

#pragma mark ------- Lazy Methods -------

- (void)fragmentUI_ViewSet {
    [self.backColorImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.view);
    }];
}

- (UIImageView *)backColorImageView {
    if (!_backColorImageView) {
        _backColorImageView = [[UIImageView alloc] initWithImage:kImageName(@"intelligence_bg_img")];
        _backColorImageView.contentMode = UIViewContentModeScaleAspectFill;
        _backColorImageView.userInteractionEnabled = YES;
    }
    return _backColorImageView;
}

@end
